package com.itheima.web.controller.ums;

import com.itheima.result.ResultData;
import com.itheima.service.ums.UmsResourceCategoryService;
import com.itheima.vo.ums.UmsResourceCategory;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("resourceCategory")
public class UmsResourceCategoryController {
    @DubboReference
    private UmsResourceCategoryService umsResourceCategoryService;
    @PostMapping("create")
    public ResultData create(@RequestBody UmsResourceCategory umsResourceCategory){
        umsResourceCategoryService.save(umsResourceCategory);
        return ResultData.ok("操作成功","");
    }
    @PostMapping("delete/{id}")
    public ResultData delete(@PathVariable Integer id){
        return umsResourceCategoryService.delete(id);
    }
    @GetMapping("listAll")
    public ResultData listAll(){
        return ResultData.ok("操作成功",umsResourceCategoryService.list());
    }
    @PostMapping("update/{id}")
    public ResultData update(@PathVariable Integer id,@RequestBody UmsResourceCategory umsResourceCategory){
        umsResourceCategory.setId(id);
        umsResourceCategoryService.updateById(umsResourceCategory);
        return ResultData.ok("操作成功","");
    }

}
